#pragma once
#include "framework.h"
#include "Renderer.h"

#include "DXUTgui.h"

using namespace poly;

#define BTNSIZE        8


//Description: Main class for the editor, 
//Handles creating/scaling/rotating polygons by mouse
//Also saving/opening those to/from file
class Game : public IGame
{
public:
	Game( HINSTANCE hInst, HWND hWnd );
	~Game();

	void onCreateGraphics( D3DDevice device );
	void onResetGraphics( D3DDevice device );

	void onFrameMove(float dt);
	void onFrameRender(float dt);

	void onLostGraphics();
	void onDestroyGraphics();

	bool msgProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );

	void		 getWindowSettings(int &, int &, bool &, bool &, bool &);
	void		 initializeEditor();
	void         onResize(int, int);
	void		 printScr(const char *string);
	void		 handleInput();
	float3       screenToPickRay(float2 mousePos);//Convert Scrren point to normalized world ray


public:
	CDXUTDialog m_Hud;
	bool m_bMouse[3];
	bool m_bKeys[256];

private:
	D3DDevice	m_d3dDevice;

	SInput		m_input;
	Camera		m_camera;

	HWND        m_hWnd;//Save window handle for later use

	std::auto_ptr<ConvexSet>	m_convexSet;
	PolygonList				    m_polygons;
	poly::Polygon	m_polygon;
	Renderer        m_Renderer;
	vector<float3>  m_colors;
	
	//GUI Vars
	CDXUTDialogResourceManager m_ResManager;
	//CD3DSettingsDlg m_SettingsDlg;

	//Save Screen Size for later use
	int m_scrWidth, 
		m_scrHeight;
	int m_fov;

	//Gui vars
	float2 m_cPositions[BTNSIZE];

};
